﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;


namespace MLY.admin
{
  public partial class adminDefault : Bll.BasePage
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      txtAdminText.Enabled = false;
    }

    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {
      txtAdminText.Enabled = true;
    }

    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
      Dictionary.UpdateTerm("adminDefault.txtAdminText", txtAdminText.Text);
      txtAdminText.Enabled = false;
    }
    protected void ClearTadbik(object sender, EventArgs e)
    {
        string Message = "Clear tadbik operation succeeded";
        using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MLYConnectionString"].ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("SP_ClearTadbik", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Log.WriteError("Error during clear tadbik operation", ex);
                Message = "Error during clear Tadbik operation: " + ex.Message;
            }
            finally
            {
                conn.Close();
            }
        }
        UpdateMessageLabel.Text = Message;
    }

    protected void ClearLithotech(object sender, EventArgs e)
    {
        string Message = "Clear Lithotech operation succeeded";
        using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MLYConnectionString"].ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("SP_ClearLithotech", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                conn.Open();
                cmd.CommandTimeout = 600;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Log.WriteError("Error during clear Lithotech operation", ex);
                Message = "Error during clear Lithotech operation: " + ex.Message;
            }
            finally
            {
                conn.Close();
            }
        }
        UpdateMessageLabelLitotech.Text = Message;
    }

      
  }
}
